package cn.hl.sfzy.service.impl;

import cn.hl.sfzy.entity.Article;
import cn.hl.sfzy.entity.Articletype;
import cn.hl.sfzy.entity.Heartknowledge;
import cn.hl.sfzy.entity.Heartmark;
import cn.hl.sfzy.mapper.ArticleMapper;
import cn.hl.sfzy.mapper.ArticletypeMapper;
import cn.hl.sfzy.mapper.HeartknowledgeMapper;
import cn.hl.sfzy.service.ArticletypeService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

@Service
public class ArticletypeServiceImpl implements ArticletypeService {
    @Autowired
    private ArticletypeMapper articletypeMapper;
    @Autowired
    private ArticleMapper articleMapper;
    @Override
    public int add(Articletype articletype) {
        int i = articletypeMapper.add(articletype);;
        return i;
    }

    @Override
    public int deleteById( Long id) {
         int delete = articleMapper.deleteType(id);
        return articletypeMapper.deleteById(id);
    }

    @Override
    public int updateid( Long id,Long[] o) {
        System.out.println(id);
        System.out.println(Arrays.toString(o));
        for (int i = 0; i < o.length; i++) {
            int updateid = articleMapper.updateid(id,o[i]);
        }



        return 1;
    }


    @Override
    public int update(Articletype articletype) {final int update = articletypeMapper.update(articletype);
        return update;
    }



    @Override
    public PageInfo<Articletype> findBypage(int pageNum, int pageSize, Articletype articletype) {
        List<Articletype> select = articletypeMapper.findAll(articletype);
        PageInfo pageHelper = new PageInfo<Articletype>(select);
        return pageHelper;
    }

}
